home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 34.zip
/
BS1 part 34
/
Weubblers handler.adf
/
examples
/
format40.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-01-10
|
1KB
|
49 lines
int Drive;
main(argc,argv)
int argc;
char **argv;
{
unsigned short *TrackBuffer;
unsigned char *SectorBuffer;
int List[30];
int drive,track,head;
int numsecs;
char c;
int Error,i;
drive=0;
numsecs=10;
while (argc-->1)
{i=atoi(argv[argc]);
if (i<4) drive=i;
else numsecs=i;}
printf("WARNING!!! This program will format the disks in drive %d with %d sectors/Track\n",drive,numsecs);
printf("in MSDOS format. IS THIS WHAT YOU REALLY WANT TO DO????\n");
scanf("%c",&c);
if (toupper(c)!='Y') {printf("Poooh... Finishing.\n");_abort();}
Drive=drive;
InitMotor();
TrackBuffer=(unsigned short *)AllocChipMem(2*TrackLen);
SectorBuffer=(unsigned char *)AllocNormalMem(512);
CreateEmptyStandardTrack(TrackBuffer,0,0,numsecs);
CreateList(TrackBuffer,List);
CreateStandardBootSector(SectorBuffer,40,2,numsecs);
WriteList(TrackBuffer,SectorBuffer,1,List);
ChangeStandardTrack(TrackBuffer,0,0,numsecs);
WriteTrack(TrackBuffer,drive,0,0);
for (i=0;i<512;i++) SectorBuffer[i]=0;
WriteList(TrackBuffer,SectorBuffer,1,List);
for (track=0;track<40;track++)
for (head=0;head<2;head++)
if (track|head)
{
ChangeStandardTrack(TrackBuffer,track,head,numsecs);
Error=WriteTrack(TrackBuffer,drive,track,head);
if (Error) {aprintf(stderr,"Error writing track %d.\n",track);_abort();}
}
_abort();
}